package com.nCoV.EpidemicSurveillance.common.utils;

import java.util.Map;

import org.springframework.security.core.Authentication;
import org.springframework.security.core.context.SecurityContextHolder;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;

/** 
* @author 作者 罗穆健: 
* @version 创建时间：2020年1月8日 下午10:54:57 
* 类说明 
*/
public class GetUserName {

	public static String getName() {
		Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
		Map<String,Object> map = JSONObject.parseObject(JSON.toJSONString(authentication.getPrincipal()));
		return (String) map.get("name");
	}
	public static String getUserName() {
		Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
		Map<String,Object> map = JSONObject.parseObject(JSON.toJSONString(authentication.getPrincipal()));
		return (String) map.get("username");
	}
}
 